home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13429 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: news.primenet.com!jstern
  2. From: jstern@primenet.com (Josh Stern)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Need help using g++ and Templates
  5. Date: 25 Mar 1996 23:23:01 -0700
  6. Organization: Primenet Services for the Internet
  7. Sender: root@primenet.com
  8. Message-ID: <4j82g5$n5d@nnrp1.news.primenet.com>
  9. References: <4j7017$8m4@sal-sun133.usc.edu>
  10. Keywords: templates g++
  11. X-Posted-By: jstern@usr2.primenet.com
  12.  
  13. Richard Radford <radford@sal-sun133.usc.edu> wrote:
  14. >I have created object files for the template class and the files that 
  15. >use instances of the template class. When I compile using g++ version 
  16. >2.7 I get errors saying I have a bunch of undefined symbols. The 
  17. >template i'm trying to use is for lists. All the 
  18. >undefined symbols are of the form List<Class I'm trying to create a 
  19. >list of>::member_function_of_template. Can anyone offer any advice on 
  20. >how to compile templates using g++. Any help would be greatly 
  21. >appreciated. 
  22.  
  23. First read the relevant sections of the info file for GCC,
  24. under the sub-heading C++ extensions.  But here is what
  25. I do:  put templates in .h files and use #pragma interface
  26. with those.  Then make sure that each such file gets
  27. 'associated' with exactly one .cc file and use #pragma
  28. implementation with that file.  The association defaults
  29. to the files with the same stem name, so you need to
  30. do explicit #pragma implementation "file.h" for cases
  31. without "file.cc" in, say, you main.cc module.
  32.  
  33.  
  34. - Josh
  35.  
  36.  
  37.  
  38. --
  39. -------------------------------------------------------------------------------
  40. jstern
  41. jstern@primenet.com
  42. -------------------------------------------------------------------------------
  43.